﻿
Imports System.IO
Imports xmlctrl
Imports xhtmlctrl
Imports webctrl

Public Class traversal
    Inherits filetraversal

    Public Shadows Const _pathidentity As String = "/"

    Public Overrides Function pathidentity() As String
        Return _pathidentity
    End Function

    Protected Overrides Sub addfileResponseHeaders(ByVal context As httpContext)
        MyBase.addfileResponseHeaders(context)
        assert(Not context Is Nothing, "context is nothing.")
        context.setcontentType(network.http.contentType.texthtmlUtf8)
    End Sub

    Protected Overrides Function processFile(ByVal context As httpContext, _
                                             ByVal path As String, ByRef control As xmlcontrol) As Boolean
        Dim page As xhtmlpage = Nothing
        page = context.createControl(New xhtmlpage())
        page.title().text = applicationSign()

        Dim img As img = Nothing
        img = context.createControl(New img())
        img.src = drawer.generateDrawerUrl(context)
        page.body().addchild(img)
        page.body().addchild(context.createControl(New br()))

        Dim form As form = Nothing
        form = context.createControl(New form())
        form.action = filename(path)
        page.body().addchild(form)

        Dim label As label = Nothing
        label = context.createControl(New label())
        label.text = "filter"
        form.addchild(label)

        Dim input As input = Nothing
        input = context.createControl(New input())
        input.type = xhtmlctrl.input.type_enum.text
        input.name = drawer.query.filter
        form.addchild(input)

        input = context.createControl(New input())
        input.type = xhtmlctrl.input.type_enum.submit
        input.value = "submit"
        form.addchild(input)

        page.body().addchild(context.createControl(New br()))
        page.body().addchild(generateBackToParent(context, path))
        control = page
        Return True
    End Function

#If RETIRED Then
    Protected Overrides Sub addresponseHeaders(ByVal context As httpContext)
        addresponseHeaders(context, [delegate].fullpath(context, strlen(pathidentity())))
    End Sub
#End If

    Protected Overrides Function processImpl(ByVal context As httpContext, ByRef control As xmlcontrol) As Boolean
        If processImpl(context, [delegate].fullpath(context, strlen(pathidentity())), control) Then
            If Not control Is Nothing Then
                convertor.cast(Of xhtmlpage)(control).title().text = applicationSign()
            End If
            Return True
        Else
            Return False
        End If
    End Function
End Class
